import request from '../utils/request.js'
// 获取用户文章分类列表
export const getUserChannels = () => {
    return request({
        method: 'GET',
        url: '/v1_0/user/channels'
    })
}
// 获取文章列表
export const getUserArticle = (data) => {
    return request({
        method: 'GET',
        url: '/v1_0/articles',
        params: data
    })
}
// 获取所有文章分类列表
export const getAllChannels = () => {
    return request({
        method: 'GET',
        url: '/v1_0/channels'
    })
}
// 修改用户频道列表
export const setMyChannels = (channels) => {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/channels',
        data: {
            channels: [channels]
        }
    })
}
// 删除用户频道列表
export const deleteMyChannels = (id) => {
    return request({
        method: 'DELETE',
        url: '/v1_0/user/channels/' + id
    })
}
// 获取新闻详情
export const getArticle = (id) => {
    return request({
        method: 'GET',
        url: '/v1_0/articles/' + id
    })
}
// 收藏文章
export const collectedArticle = (target) => {
    return request({
        method: 'POST',
        url: '/v1_0/article/collections',
        data: {
            target
        }
    })
}
// 取消收藏文章
export const deleteCollected = (id) => {
    return request({
        method: 'DELETE',
        url: '/v1_0/article/collections/' + id
    })
}
// 点赞文章
export const likedArticle = (target) => {
    return request({
        method: 'POST',
        url: '/v1_0/article/likings',
        data: {
            target
        }
    })
}
// 取消点赞
export const deleteLiked = (id) => {
    return request({
        method: 'DELETE',
        url: '/v1_0/article/likings/' + id
    })
}
// 获取用户文章列表
export const getUserAllArticle = (data) => {
    return request({
        method: 'GET',
        url: `/v1_0/users/${data.id}/articles`,
        params: {
            page: data.pageNum,
            per_page: data.pageSize
        }
    })
}
